-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Optimization for shell sort #4038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I do not quite understand the title of this PR. In what way is the current implementation broken? |
We should insert value instead of swapping elements of array. |
Is your implementation improve performance or what? If so please write proper tests for proof that your solution is better than already exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need additional tests for performance
Maybe we can strictly follow this?: https://en.wikipedia.org/wiki/Shellsort#Pseudocode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may add a reference to the wiki page as well.
@poyea Done. Please review again. |
""" | ||
This is a pure Python implementation of the shell sort algorithm | ||
|
||
For doctests run following command: | ||
python -m doctest -v shell_sort.py | ||
or | ||
python3 -m doctest -v shell_sort.py | ||
|
||
For manual testing run: | ||
python shell_sort.py | ||
https://en.wikipedia.org/wiki/Shellsort#Pseudocode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave the first line like this
""" | |
This is a pure Python implementation of the shell sort algorithm | |
For doctests run following command: | |
python -m doctest -v shell_sort.py | |
or | |
python3 -m doctest -v shell_sort.py | |
For manual testing run: | |
python shell_sort.py | |
https://en.wikipedia.org/wiki/Shellsort#Pseudocode | |
""" | |
This is a Python implementation of the shell sort algorithm. | |
Reference: https://en.wikipedia.org/wiki/Shellsort#Pseudocode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would approve this as the original version has really no reference to the algorithm (or at least, the implementation didn't strictly follow the algorithm). Thank you for your pull request!🤩
Co-authored-by: John Law <[email protected]>
@poyea Done |
@mateuszz0000 Can you review again. Thanks :) |
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <[email protected]> Co-authored-by: John Law <[email protected]>
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <[email protected]> Co-authored-by: John Law <[email protected]>
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <[email protected]> Co-authored-by: John Law <[email protected]>
* fixed shell sort * udpate code style * Update sorts/shell_sort.py Co-authored-by: John Law <[email protected]> Co-authored-by: John Law <[email protected]>
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.